using System;
using System.Diagnostics;
using System.IO;

namespace OracleInternal.Common
{
	internal class ThreadData : IDisposable
	{
		internal Stream traceFile;

		internal TextWriterTraceListener textListener;

		internal long traceFileSize;

		internal string traceFilePath;

		internal int timeStampHash = TimeStampHash;

		internal static int TimeStampHash = DateTime.Now.GetHashCode();

		internal bool IsOutdated => timeStampHash != TimeStampHash;

		internal static void RegenerateTimeStampHash()
		{
			TimeStampHash = DateTime.Now.GetHashCode();
		}

		public void Dispose()
		{
			if (textListener != null)
			{
				textListener.Dispose();
			}
			textListener = null;
			timeStampHash = 0;
			traceFilePath = null;
			traceFileSize = 0L;
		}

		~ThreadData()
		{
			try
			{
				Dispose();
			}
			catch
			{
			}
		}
	}
}
